<?php

namespace fastphp\facade;

use fastphp\util\Header;

final class Response
{
    public static function create($msg, $data = [], $code = 200, $extra = [])
    {
        Header::setJsonHeader();
        $ls = [
            'code' => $code,
            'msg' => $msg,
        ];
        if (!empty($extra)) {
            foreach ($extra as $key => $item) {
                $ls[$key] = $item;
            }
        }
        $ls['data'] = $data;
        echo json_encode($ls, true);
    }
}